// API根路径
axios.defaults.baseURL = "http://localhost:8888/";
// 响应头
axios.interceptors.request.use(function (config) {

    if (config.url.startsWith("/admin")) {
        config.headers["Authorization"] = sessionStorage.getItem("token");
    }

    return config
}, function (error) {
    return Promise.reject(error)
})

//获取轮播图
const swiperGetAPI = function (fn) {
    axios({
        url: "/admin/swipers",
        method: "GET"
    }).then(fn)
}
//修改轮播图
const swiperPutAPI = function (arg, fn) {
    axios({
        url: "/admin/swipers/" + arg.id,
        method: "PUT",
        data: arg
    }).then(fn)
}
//上传轮播图
const swiperUpAPI = function (arg, fn) {
    axios({
        url: "/admin/swipers",
        method: "POST",
        data: arg
    }).then(fn)
}
//删除轮播图
const swiperDelAPI = function (arg, fn) {
    axios({
        url: "/admin/swipers/" + arg,
        method: "DELETE"
    }).then(fn)
}

